﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using SmlEngine.Graphics;

namespace Sml.Scenes.WorldMap
{
    /// <summary>
    /// A tile for the world map.
    /// </summary>
    public class WorldMapTile
    {
        #region Properties and Fields

        private string _contentPath;
        /// <summary>
        /// The path to the tilesheet containing the graphics to use.
        /// </summary>
        public string contentPath
        { get { return _contentPath; } }


        private Vector2 _location;
        /// <summary>
        /// The location of this tile on the world map.
        /// </summary>
        public Vector2 location
        { get { return _location; } }

        /// <summary>
        /// The texture of the tile.
        /// </summary>
        private Texture2D texture;

        #endregion

        /// <summary>
        /// Creates a new WorldMapTile.
        /// </summary>
        /// <param name="c_contentPath">The path to the tilesheet to use.</param>
        /// <param name="c_sourceRect">The area of the tilesheet which has the tile.</param>
        /// <param name="c_location">The location of the tile on the world map.</param>
        public WorldMapTile(ref SpritesheetManager sm, string c_contentPath, Rectangle c_sourceRect, Vector2 c_location, ContentManager cm)
        {
            try
            {
                texture = sm.GetTile(c_contentPath, c_sourceRect, cm);
                _location = c_location;
                _contentPath = c_contentPath;
            }
            catch
            {
                string message = String.Concat("An error occured in loading the world.  [WorldMapTile.ctor()]");
            }
        }

        public void Draw(GameTime gameTime, SpriteBatch sb)
        {
            sb.Draw(texture, location, Color.White);
        }
    }
}
